package com.gxa.modules.pc.order.controller;

import com.gxa.common.utils.Result;
import com.gxa.common.utils.TPage;
import com.gxa.modules.pc.order.service.BookPhyCheckService;
import com.gxa.modules.model.entity.book.BookPhyCheck;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.HashMap;

/**
 * <p>
 * 预约体检表 前端控制器
 * </p>
 *
 * @author zhuiyi
 * @since 2022-11-12 09:47:44
 */
@Api(tags = "预约体检")
@Slf4j
@RestController
public class BookPhyCheckController {
    @Autowired
    private BookPhyCheckService bookPhyCheckService;

    @ApiOperation("查询所有  预约体检")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "pageNum",value = "当前在那一页",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "pageSize",value = "每页多少条记录",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "status",value = "状态",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "startTime",value = "开始时间",dataType = "String"),
            @ApiImplicitParam(paramType = "query",name = "endTime",value = "结束时间",dataType = "String"),
            @ApiImplicitParam(paramType = "query",name = "orderField",value = "根据什么字段排序",dataType = "String"),
            @ApiImplicitParam(paramType = "query",name = "order",value = "升序-asc 降序-desc （不是asc都是降序）",dataType = "String"),
    })
    @GetMapping("/book-phy-check/list")
    public Result list(@RequestParam @ApiIgnore HashMap<String,Object> searchMap){
        log.info("---------------{}-------------",searchMap);
        TPage tPage = bookPhyCheckService.queryByPage(searchMap);
        return new Result().ok(tPage);
    }

    @ApiOperation("查看详情  预约体检")
    @GetMapping("/book-phy-check/{id}")
    public Result add(@PathVariable Integer id) {
        BookPhyCheck byId = bookPhyCheckService.getById(id);
        if(byId!=null){
            return new Result().ok(byId);
        }
        return new Result().error();
    }


}
